//============================================================
// soundusic.cpp
//
//============================================================
//#include "stdafx.h"
#include "soundmusic.h"


#include "soundmanager.h"
#include "resourcemanager.h"


namespace core
{
		
		void SoundMusic::LoadSound( const std::string& p_File )
		{
				if( m_Audio )
						m_Audio.reset();

				m_Audio = boost::dynamic_pointer_cast<Audio>( ResourceManager::GetInstance()->GetResource( p_File ) );
				if( !m_Audio )
				{
						m_Audio = AudioPtr( new Audio );
						m_Audio->LoadAudio( p_File, true );

						ResourceManager::GetInstance()->AddResource( p_File, m_Audio );
				}

		}


		void SoundMusic::Play( int p_LoopCount )
		{
				if( !m_Audio )
						return;

				SoundManager::GetInstance()->PlayMusic( m_Audio, p_LoopCount );
		}



		void SoundMusic::SetVolume(int p_Percent)
		{
				SoundManager::GetInstance()->SetMuiscVolume( m_Audio, p_Percent );
		}


		void SoundMusic::Pause()
		{
				SoundManager::GetInstance()->PauseMusic( m_Audio );
		}

		
		void SoundMusic::Start()
		{
				SoundManager::GetInstance()->UnpauseMusic( m_Audio );

		}


		void SoundMusic::Stop()
		{
				SoundManager::GetInstance()->StopMusic( m_Audio );

		}


};




